<!-- Star of Main -->
<div class="main mt10" >
    <!-- Star of area2s -->
    <div class="area2s">
    	<!-- Star of Col1 -->
    	<div class="col1">
			<div class="breadCrumb">
                <div class="fl"><span class="cRed fb">当前位置：</span><a href="<?php echo CHtml::normalizeUrl(array('/')) ?>">首页</a>&nbsp;&rsaquo;&nbsp;<a href="<?php echo CHtml::normalizeUrl(array('/psytest')) ?>">心理测试</a>&nbsp;&rsaquo;&nbsp;<strong>开始测试</strong></div>
            </div>    
			<div class="psyTest mt20">
				<div class="boxB boxNoBg">
				<div class="boxBtop">
                	<div class="boxBt1"><div class="boxBt2"><div class="boxBt3"><h2><?php echo htmlspecialchars($topic->topicTitle) ?></h2></div></div></div>
                </div>
                <div class="boxBmiddle">
					<div class="psyTest-inner">
						<div class="content">
						<div class="status"><span class="cOrg"><img src="<?php echo Yii::app()->baseUrl ?>/images/write_ok.gif" alt="" />(<?php echo $topic->testedCount ?>人测过)</span><span class="cOrg"><img src="<?php echo Yii::app()->baseUrl ?>/images/replay.gif" alt="" />(<?php echo $topic->commentCount ?>评论)</span> <a href="" id="viewComment">[查看/发表评论]</a></div>
						<table cellpadding="0" cellspacing="0" border="0" width="100%">
							<tr>
								<td width="180" align="center"><div class="test-img"><img src="<?php echo $topic->getImageUrl('m') ?>" alt="<?php echo htmlspecialchars($topic->topicTitle) ?>" title="<?php echo htmlspecialchars($topic->topicTitle) ?>" width="150" /></div></td>
								<td><p class="test-intro"><?php echo nl2br(htmlspecialchars($topic->topicDescr)) ?><br />本测试<?php if($topic->getTypeCatalog() ==  'jumping') : ?>为跳转题，共<?php endif ?> <span class="cRed"><?php echo $topic->questionCount ?></span> 道题。用鼠标点选答案选项后按回车键即可提交答案。</p>
								<?php if($hasTested) : ?><p class="cOrg mt10" style="margin-left: 15px;">您已参加过此测试，<?php if($isRedo) : ?><a href="<?php echo CHtml::normalizeUrl(array('/psytest/index', 'id' => $topic->topicId)) ?>" class="cRed aTd">查看测试结果</a><?php else: ?>可以<a href="<?php echo CHtml::normalizeUrl(array('/psytest/index', 'id' => $topic->topicId, 'redo' => '1')) ?>" class="cRed aTd">重新测试</a><?php endif ?>。重新测试的结果不会加入到您的测试记录中。</p><?php elseif(Yii::app()->user->id === null) : ?><p class="state mt10">登录用户才能查看测试结果。<a href="<?php echo CHtml::normalizeUrl(array('/users/signin', 'rf' => urlencode(Yii::app()->request->pathInfo))) ?>" class="cRed aTd">登录</a>或者<a href="<?php echo CHtml::normalizeUrl(array('/users/signup')) ?>" class="cRed aTd" target="_blank">花十秒钟注册一下</a>。本站所有心理测试免费开放。</p><?php endif ?>
								<div class="tr mt10"><!-- JiaThis Button BEGIN --><a href="http://www.jiathis.com/share.html" class="jiathis"><img src="http://www.jiathis.com/code/images/jiathis.gif" width="125" height="21" border="0" id="jiathis_a"/></a><script type="text/javascript" src="http://www.jiathis.com/code/jia.js" charset=utf-8></script><!-- JiaThis Button END --></div></td>
								</tr>
							</table>
						</div>
					</div>
				</div>
				<div class="boxBbottom">
                	<div class="boxBb1"><div class="boxBb2"><div class="boxBb3"></div></div></div>
                </div>
				</div>
				<div id="test_question_box" class="mt20">
						<?php if( ! $isViewConclusion) : ?>
						<?php $this->widget('TestQuestion', array('question' => $question)) ?>
						<?php else : ?>
						<?php $this->widget('ViewTestConclusion', array('conclusions' => $conclusions)) ?>
						<?php endif ?>
				</div>
			</div>
		    <div class="replyList mt20" id="commentsListBox" style="display: none">
            	<div class="title aRed fb" id="t1"><?php if($topic->commentCount > 0) : ?><a href="#commentsList">共有<span>&thinsp;<?php echo $topic->commentCount ?>&thinsp;</span>评论</a><?php else : ?>暂无评论<?php endif ?>&nbsp;<span class="fn cHui1">|</span>&nbsp;<a href="#postComment">我要评论</a></div>
            	<?php if($topic->commentCount > 0) : ?>
		        <ul class="commentList mt10" id="commentsList">
		        <?php foreach($topic->comments as $comment) : ?>
                       <li>
                            <div class="comment">
	                            <div class="posttime">发表于<?php echo fromNow($comment->commentedAt) ?> </div>
	                            <div class="author">
									<img src="<?php echo $comment->author->getAvatarUrl('s') ?>" width="48" height="48" />
									<a href="<?php echo CHtml::normalizeUrl(array('/users/viewprofile', 'id' => $comment->author->uid)) ?>" class="cGre"><?php echo $comment->author->userName() ?></a>
								</div>
	                            <p><?php echo htmlspecialchars($comment->commentContent) ?></p>	
								<div class="cb"></div>
                            </div>
                        </li>
				<?php endforeach ?>
                </ul>
                <?php endif ?>
			</div>
            <div class="post mt10" id="postComment" style="display: none">
    			<div class="postInner">
        		<h3 id="t2">发表评论</h3>
       			 <?php if( ! Users::isLogin()) : ?><div class="state mt10">您尚未<?php echo CHtml::link('登录', array('/users/signin'), array('class' => 'cRed'))?>。还不是会员？点击<?php echo CHtml::link('这里', array('/users/signup'), array('class' => 'cRed')); ?>注册。</div>
				<?php else : ?><div class="mt10">你好，<?php echo Yii::app()->user->name; ?>，评论一下“<?php echo htmlspecialchars($topic->topicTitle) ?>”吧。</div><?php endif; ?>
                <?php echo CHtml::form(array('/psytest/createcomment', 'id' => $topic->topicId)) ?>
                <?php echo CHtml::activeHiddenField($_comment, 'topicId', array('value' => $topic->topicId)) ?>
                <table cellpadding="0" cellspacing="0" class="mt10">
                    <tr>
                    	<td valign="top" class="tr">内容：</td>
                        <td><?php echo CHtml::activeTextArea($_comment, 'commentContent', array('class' => 'ipt3','style' => "width:400px; height:90px;")); ?></td>
                    </tr>
                    <tr>
                    	<td valign="top" class="tr">验证码：</td>
                        <td>
                            <?php echo CHtml::activeTextField($_comment, 'verifyCode', array('class' => 'ipt3', 'size' => '15')); ?>
                            <?php $this->widget('CCaptcha', array('captchaAction' => 'captcha', 'buttonLabel' => '看不清？换张图', 'buttonOptions' => array('class' => 'cOrg', 'height' => '25px', 'style' => "margin-left :5px;")))?>
                        </td>
                    </tr>
                    <?php if($_comment->hasErrors()) : ?>
                    <tr>
                    	<td>&nbsp;</td>
                        <td>
                        <div class="notice_error"><?php foreach($_comment->getErrors() as $error) : echo $error[0]; endforeach; ?></div>
                        </td>
                    </tr>
                    <?php endif; ?>
                    <tr>
                    	<td></td>
                        <td><input type="submit" class="btn1" value="提  交" /></td>
                    </tr>
                </table>
        		<?php echo CHtml::endForm(); ?>
        		</div>
			</div>
		</div>
        <!-- End of Col1 -->
        <!-- Star of Col2 -->
        <div class="col2">
            <?php $this->widget('Inform') ?>
            <?php $this->widget('RecommendPsytest') ?>
            <?php if($this->beginCache('hot-psytests', array('duration' => 604800))) : ?>
            <?php $this->widget('HotPsytests') ?>
            <?php $this->endCache() ?>
            <?php endif ?>
            <?php // $this->widget('LatestPosts') ?>
            <?php // $this->widget('HotThreads') ?>
			<div class="smallAd mt10"><?php echo CHtml::image(Yii::app()->baseUrl.'/images/a-exp2.png', '慧苑心理咨询专注于解决婚姻家庭亲子问题', array('title' => '慧苑心理咨询专注于解决婚姻家庭亲子问题')); ?></div>
            <?php if(count($otherTopics) > 0) : ?>
           <div class="boxA artTop mt10">
                <div class="boxAtop">
                    <div class="boxAt1"><div class="boxAt2"><div class="boxAt3"><h3>其它同类测试</h3></div></div></div>
                </div>
                <div class="boxAmiddle">
                    <ul>
                    <?php foreach($otherTopics as $k => $_topic) : ?>
                    <?php if($_topic !== null) : ?>
                        <li<?php if($k==9):?> id="styleNone"<?php endif; ?>><a title="<?php echo htmlspecialchars($_topic->topicTitle); ?>" href="<?php echo CHtml::normalizeUrl(array('/psytest/index', 'id' => $_topic->topicId)) ?>" target="_blank"><?php echo htmlspecialchars(truncStr($_topic->topicTitle, 39)); ?></a></li>
                    <?php endif ?>
                    <?php endforeach; ?>
                    </ul>
                </div>
                <div class="boxAbottom">
                    <div class="boxAb1"><div class="boxAb2"><div class="boxAb3"></div></div></div>
                </div>
            </div>
            <?php endif ?>
        </div>
        <!-- End of Col2 -->
    </div><!-- End of area3s -->
</div>
<!-- End of Main --> 
<script type="text/javascript">
$.ajaxSetup({
    timeout : 60000,
    error   : function() {
        alert('抱歉，超时或连接错误，请您刷新页面重试，测试会从断点处继续进行。');
    }
});

$(document).ready(function(){
	$('#viewComment').click(function() {
		if($('#commentsListBox').css('display') == 'none') {
			$('#commentsListBox').show();
			$('#postComment').show();
			window.location.hash = 'commentsListBox';
		} else {
			$('#commentsListBox').hide();
			$('#postComment').hide();
		}
		return false;
	});
	if(window.location.hash == '#postComment') {
		$('#commentsListBox').show();
		$('#postComment').show();
		window.location.hash = '#postComment';
	}

	$("ul#commentsList li").mouseover(function(){
		$(this).addClass("over");}).mouseout(function(){
		$(this).removeClass("over");});
	$("ul#commentsList li:odd").addClass("alt");
	$("ul#commentsList li:last").css('border-bottom', 'none');
});
$(document).keypress(function(e) {
    if(e.which == 13) {
        $('#psy_test_form').submit();
    }
});
</script>
